<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var i = Number(prompt("请输入你需要打印几行的三角形"));

        for(var j=1; j<=i ; j++){
            for(var p=j; p<=i;p++){
                    document.write("&nbsp;");
                }
            for(var k=1;k<=j;k++){
                document.write(' * ');
            }
            document.write('<br>');
        }
    </script>
</body>
</html>